﻿<common:LayoutAwarePage
    x:Class="Looptribe.Moodlin8.View.DayEventsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:common="using:Looptribe.Moodlin8.Common"
    DataContext="{Binding DayEvents, Source={StaticResource Locator}}"
    mc:Ignorable="d">
    
    <Page.Resources>
        <DataTemplate x:Key="EventTemplate">
            <Grid Height="70" Margin="2" Width="300">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal">
                    <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="70" Height="70">
                        <ContentControl Template="{StaticResource DateBlockTemplate}" />
                    </Border>
                    <Border BorderThickness="1" Width="230" Height="70" BorderBrush="#FFD3D3D3" Background="{StaticResource HubListItemBackground}">
                        <StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0" Width="220" >
                            <!--<TextBlock Text="{Binding Id, Converter={StaticResource CourseTitleBinder}}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap"/>-->
                            <TextBlock Text="{Binding Name}" Style="{StaticResource SubtitleTextStyle}" TextWrapping="NoWrap"/>
                            <TextBlock Text="{Binding DateTime}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Grid>
        </DataTemplate>
    </Page.Resources>

    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ProgressBar IsIndeterminate="True" Grid.Row="1" Visibility="{Binding IsLoading,Converter={StaticResource BooleanToVisibilityConverter}}" />

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{Binding Date,Converter={StaticResource dateConverter}}" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/>
        </Grid>

        <!--<ListView x:Name="hubNextAssignmentsListview" Grid.Row="1" Margin="0,20,0,0" Width="330" Height="Auto" ItemsSource="{Binding Assignments}" ItemTemplate="{StaticResource NextAssignmentsTemplate}" SelectionMode="None" IsSwipeEnabled="False"/>-->
        <ListView Padding="116,0,116,46" Grid.Row="1" Margin="0,20,0,0" ItemsSource="{Binding Events}" ItemTemplate="{StaticResource EventTemplate}" SelectionMode="None" IsSwipeEnabled="False">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapGrid Orientation="Vertical" />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
        </ListView>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>